package com.eos.orm.mybatis.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.eos.orm.mybatis.dao.SysCustomerMapper;
import com.eos.orm.mybatis.model.SysCustomer;
import com.eos.orm.mybatis.model.SysCustomerExample;
/**
 * sys_customer客户表的CURD操作
 * @author sz
 *
 */
public class SysCustomerMapperImpl extends AbstractSqlSessionFactory implements
		SysCustomerMapper {

	public int countByExample(SysCustomerExample example) {
		return 0;
	}

	public int deleteByExample(SysCustomerExample example) {
		return 0;
	}

	public int deleteByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysCustomerMapper mapper = session.getMapper(SysCustomerMapper.class);
			mapper.deleteByPrimaryKey(id);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysCustomerMapperImpl.deleteByPrimaryKey throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insert(SysCustomer record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysCustomerMapper mapper = session.getMapper(SysCustomerMapper.class);
			mapper.insert(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysCustomerMapperImpl.insert throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insertSelective(SysCustomer record) {
		return 0;
	}

	public List<SysCustomer> selectByExample(SysCustomerExample example) {
		List<SysCustomer> templist = new ArrayList<SysCustomer>();
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysCustomerMapper mapper = session.getMapper(SysCustomerMapper.class);
			templist = mapper.selectByExample(example);
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysCustomerMapperImpl.selectByExample throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return templist;
	}

	public SysCustomer selectByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysCustomerMapper mapper = session.getMapper(SysCustomerMapper.class);
			return mapper.selectByPrimaryKey(id);
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysCustomerMapperImpl.selectByPrimaryKey throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return null;
	}

	public int updateByExample(SysCustomer record, SysCustomerExample example) {
		return 0;
	}

	public int updateByExampleSelective(SysCustomer record,
			SysCustomerExample example) {
		return 0;
	}

	public int updateByPrimaryKey(SysCustomer record) {
		return 0;
	}

	public int updateByPrimaryKeySelective(SysCustomer record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysCustomerMapper mapper = session.getMapper(SysCustomerMapper.class);
			mapper.updateByPrimaryKeySelective(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysCustomerMapperImpl.updateByPrimaryKeySelective throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

}
